package cloud.security.service;

import cloud.security.vo.SecurityUser;
import cloud.security.vo.SysUser;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

import java.util.HashSet;

@Component
public class CloudUserDetailService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        SysUser sysUser = new SysUser();
        sysUser.setUsername("admin");
        sysUser.setPassword(new BCryptPasswordEncoder().encode("123456"));
        HashSet<String> permissions = new HashSet<>();
        permissions.add("admin");
        return new SecurityUser(sysUser,permissions);
    }
}
